<?php
/**
 * cms管理员添加管理页
 * author wang
 * mail:970633164@qq.com
 */

define("PHP_IN", true);
require "../include/init.php";
require "checklogin.php";
require ROOT_PATH."cms/smart_connection.php";

if (isset($_POST['dosubmit'])) {
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);
    if ($username == "" || $password == "") {
        alert("请填写完整的用户信息");
        exit;
    }
    $password_md5 = md5($password);
    $sql = "INSERT INTO admin (username,password) VALUES ('$username','$password_md5')";
    $result = $db->query($sql);
    if ($result) {
        alert("添加成功", "admin_list.php");
    } else {
        alert("添加失败");
    }

}

$smarty->display("admin_add.tpl");
$db->close();

?>
